package com.heima.feign.schedule;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.schedule.dtos.TaskDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient("leadnews-schedule")
public interface IScheduleClient {
    /**
     * 添加任务
     * @param dto
     * @return 返回任务id
     */
    @PostMapping("/api/v1/task/add")
    public ResponseResult addTask(@RequestBody TaskDto dto);

    /**
     * 按照类型和优先级拉取任务
     * @param taskType     任务类型
     * @param priority 任务优先级
     * @return 返回任务
     */
    @GetMapping("/api/v1/task/poll/{taskType}/{priority}")
    public ResponseResult popTask(@PathVariable("taskType") Integer taskType,
                                  @PathVariable("priority") Integer priority);
}
